package com.bookmanager.www.common.utils;

import io.jsonwebtoken.SignatureAlgorithm;
import org.apache.shiro.SecurityUtils;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: 风离
 * @Date: 2021/11/06/17:16
 * @Description: 获取用户id
 */
public class ShiroUtils {

   public static String getUserId()
   {
     String jwt = (String)SecurityUtils.getSubject().getPrincipal();
       JwtUtil jwtUtil = new JwtUtil("userId", SignatureAlgorithm.HS256);
     String userId = (String) jwtUtil.decode(jwt).get("userId");
     return userId;
   }

}
